import React, {PureComponent} from 'react';
import {connect} from 'dva';
import styles from './index.less';
import {Link} from "react-router-dom"


@connect(({article, loading}) => ({
  article,
  loading: loading.models.article,
}))
class Article extends PureComponent {

  state = {

  }

  componentDidMount() {
    const {dispatch, match} = this.props
    const {params} = match
    dispatch({
      type: 'article/get',
      payload: {
        id:params.id
      }
    })

  }

  render() {
    const {article:{data}} = this.props
    let content = data.content.replace(/\n/g,'<br>')
    return (
      <div className={styles.container}>
        <div className={styles.title}>{data.title}</div>
        <div className={styles.content}>
          <div dangerouslySetInnerHTML={{__html: content}}/>
        </div>
      </div>
    )
  }
}

export default Article;
